package com.ifyyf.service;

import com.ifyyf.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author if
 * @Description: 服务降级
 * @Date 2021-08-26 下午 03:18
 */
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {
    @Override
    public DeptClintService create(Throwable throwable) {
        return new DeptClintService() {
            @Override
            public List<Dept> queryAll() {
                return null;
            }
            @Override
            public Dept queryById(Long deptno) {
                return new Dept()
                        .setDeptno(deptno)
                        .setDname("无法查询id为"+deptno+"的数据，为了分担其他服务的压力，该服务现已被关闭")
                        .setSource("服务关闭，无法查询");
            }
        };
    }
}
